<?
	include_once('global.inc.php');
	if(isset($_REQUEST['card_num'])){
		require_once '../AuthNet/anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct.
		$transaction = new AuthorizeNetAIM($API_LOGIN_ID, $TRANSACTION_KEY);
		
		$transaction->amount = $_REQUEST['amount'];
		$transaction->card_num = $_REQUEST['card_num'];
		$transaction->exp_date = $_REQUEST['exp_date'];
		
		$response = $transaction->authorizeAndCapture();
		
		if ($response->approved) {
			//Record Transaction ID in Database
			//Redirect to Sucess page
		  echo "<h1>Success! The test credit card has been charged!</h1>";
		  echo "Transaction ID: " . $response->transaction_id;
		} else {
		  echo $response->error_message;
		}
	}else{
		//display form
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
    </head>
    
    <body>
    	<form method="post">
        	<label>Amount:</label>
            <input name="amount" />
            <label>Credit Card Number:</label>
            <input name="card_num" value="4001000044446598" />
            <label>Experation Date:</label>
            <input name="exp_date" />
            <br />
			<input type="submit" />
        </form>
    </body>
</html>